import re

# url = 'http://www.zhanghanyi.com/love/wangjia?duration=forever'
url = 'http://www.zhanghanyi.com/love/wangjia?duration=forever'
# url = 'abc'

# group = re.sub(r"http(s)?://\w+/","",url)
# str = re.match(r"http://(.+?)/", url)
# str = re.search(r"(([01]?\d?\d|2[0-4]\d|25[0-5])\.){3}([01]?\d?\d|2[0-4]\d|25[0-5]\.)","192.168.1.1")
# if str:
#   print(str.group())
# else:
#   print('null')
# print(re.match(r'com','http://www.zhanghanyi.com/love/').group())

print(re.sub(r"http://(.+?)/.*",lambda x:x.group(1),url))